import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import { get_user_info } from './config';
import whoami from '@feidao/web/atom/browser/msg/whoami';
import nodejs from '@feidao/web/atom/browser/msg/nodejs';
import { send_msg as url } from './config';

import P001 from './P001';
import render from '@feidao/web/atom/browser/render/render';
import set from '@feidao/web/atom/core/local/set';

export default async function (fd: IFeidaoAiBrowserComponent, ...args: any[]) {

	//显示

	const user = await whoami(get_user_info) as {
		avatar_path: string;
		usercode: string;
		user_name: string;
		productid: string
	};

	console.log(user, '-----------------')

	set(fd, 'usercode', user.usercode)
	set(fd, 'productid', user.productid)

	const phone_info = await nodejs<{ _id: string, phone: string, length: number }>(url, 'phone_find', { usercode: user.usercode }, false, false);



	if (phone_info.length != 0) {
		set(fd, '_id', phone_info[0]._id)
		if (phone_info[0].phone) {
			render(fd, phone_info[0].phone, P001, 'P001', 'inner');
		}

	}

	fd.data.node.querySelector('[data-feidao-zjc="08"]').classList.remove('display-n');
	fd.data.node.classList.remove('display-n');

}

